I will really appreciate a little help on how to replace space or any character from a string or any type of text.
DB dbtest
DBE fld, fld2, btn
void replaceText (DBE btn)
{
//I need to create a function to replace or recognize the spaces in the Field box for the "|".
//This is like a search engine I want to create and
string s = get(fld)
string nTxt = "Man|Woman|Child" //Desired Text
set(fld, nTxt)
}
dbtest = create("Test DB", styleCentered)
fld = field(dbtest, "Enter Text: ", "Man Woman Child", 30, false)
right(dbtest)
btn = button(dbtest, "Replace", replaceText)
setFocus(btn)
show(dbtest)
SystemAdmin - Tue Dec 15 14:26:00 EST 2009 |
Re: DB dbtest
Hi,
DB dbtest
DBE fld, fld2, btn
char OLDCHAR = ' '
char NEWCHAR = '|'
void replaceText (DBE btn)
{
Buffer b = create
b = (string get fld)
int i
for i in 1:length b do if b[i] == OLDCHAR then set (b,i,NEWCHAR)
set(fld, stringOf b)
delete b
}
dbtest = create("Test DB", styleCentered)
fld = field(dbtest, "Enter Text: ", "Man Woman Child", 30, false)
right(dbtest)
btn = button(dbtest, "Replace", replaceText)
setFocus(btn)
show(dbtest)
|
Re: DB dbtest ePiallat - Thu Dec 17 05:32:39 EST 2009
Hi,
DB dbtest
DBE fld, fld2, btn
char OLDCHAR = ' '
char NEWCHAR = '|'
void replaceText (DBE btn)
{
Buffer b = create
b = (string get fld)
int i
for i in 1:length b do if b[i] == OLDCHAR then set (b,i,NEWCHAR)
set(fld, stringOf b)
delete b
}
dbtest = create("Test DB", styleCentered)
fld = field(dbtest, "Enter Text: ", "Man Woman Child", 30, false)
right(dbtest)
btn = button(dbtest, "Replace", replaceText)
setFocus(btn)
show(dbtest)
for i in 0:((length b) -1) do if...
|
Re: DB dbtest llandale - Thu Dec 17 13:22:16 EST 2009
Yes! of course... |
Re: DB dbtest ePiallat - Thu Dec 17 05:32:39 EST 2009
Hi,
DB dbtest
DBE fld, fld2, btn
char OLDCHAR = ' '
char NEWCHAR = '|'
void replaceText (DBE btn)
{
Buffer b = create
b = (string get fld)
int i
for i in 1:length b do if b[i] == OLDCHAR then set (b,i,NEWCHAR)
set(fld, stringOf b)
delete b
}
dbtest = create("Test DB", styleCentered)
fld = field(dbtest, "Enter Text: ", "Man Woman Child", 30, false)
right(dbtest)
btn = button(dbtest, "Replace", replaceText)
setFocus(btn)
show(dbtest)
|
Re: DB dbtest mirlo - Fri Mar 05 15:07:36 EST 2010
//*****************************************************************************************************************************
string replaceChar(string stringToClear, string sub, string new)
{
int offset
int length1
bool matchCase = true
string s1
string s2
for (findPlainText(stringToClear, sub, offset, length1, matchCase) == true)
{
s1 = stringToClear[0:offset-1]
s2 = stringToClear[offset+1:(length(stringToClear))]
stringToClear = s1 new s2
}
return stringToClear
}
//*****************************************************************************************************************************
string s = "today we've got 28°"
s = replaceChar(s, "°", "degrees")
print s ""
//prints: "today we've got 28degrees"
|